package com.loong.framework.utils;

import org.bouncycastle.crypto.digests.SM3Digest;
import org.bouncycastle.util.encoders.Hex;

public class SmUtil {

  /**
   * 国密sm3算法
   *
   * @param input
   * @return
   */
  public static String sm3(String input) {
    SM3Digest digest = new SM3Digest();
    byte[] data = input.getBytes();
    digest.update(data, 0, data.length);
    byte[] result = new byte[digest.getDigestSize()];
    digest.doFinal(result, 0);
    return new String(Hex.encode(result));
  }
}
